﻿<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.baihui.taobao.util.Util" %>
<%@ page import="java.net.URLEncoder" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<% String basePath = request.getContextPath();
   String path = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+basePath;
 %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<script type="text/javascript" src="<%=basePath%>/prototype.js"></script>
<head>
    <title></title>
</head>
<body>
	<table width="100%" border="1" cellspacing="0" cellpadding="0">
	  <tr>
	    <td>1) 帐号升级</td>
      </tr>
      <tr>
	    <td>2) 模板复制</td>
      </tr>
     <!--  
      <tr>
	    <td><a href="javascript:show()">4) 数据初始化</a>
	    	<div id="div1" style="display:none;hight:280px">
	    		<label id="name">sdfdsfdsf </label>
	    		<label id="progress">sdfdsfsdf </label>
	    	</div>
	    </td>
      </tr>
      
      <tr>
	    <td>3) 请输入crmApiKey:  <input type="text" id="crmApiKey" style="width:200px" value="${crmApiKey}"/><input type="button" id="a" value="提交" onclick="javascript:commitCrmKey()"/></td>
      </tr>
       -->
      <tr>
	    <td>3) "淘宝数据同步"web页签地址:  <a href= "<%=path%>${webAddress}" target="_blank"><%=path%>${webAddress}</a></td>
      </tr>
      <tr>
	    <td>4) "导出本地数据"web页签地址:  <a href= "<%=path%>${exportCSVpath}" target="_blank"><%=path%>${exportCSVpath}</a></td>
      </tr>
      <tr>
	    <td><a id="set" href="#" onclick="javascript:check();">5) 设置周期</a></td>
      </tr>
      <tr>
	    <td>6) 请确认以上5步是否实施完成，完成后请点击“确认”按纽。 <input type="button" value="确认" onclick="javascript:updateStatus()"></input>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="同步三个月的数据" onclick="javascrip:importOrderData()"></input></td>
      </tr>
      <s:if test="finish == 1">
      	 <tr>
	    	<td sytel="color:red">您已经完成了全部的实施过程，请通知客户可以正常使用。</td>
     	 </tr>
      </s:if>
    </table>
	
</body>
<script>

	function importOrderData(){
		var url = '<%=basePath%>/app?ACTION=importOrderData&USERID=${baihuiId}&threeMonthData=1&async=true';
		new Ajax.Request(url,{
			onComplete : callback3
		});
	}
	
	function callback3(response){
		var resText = response.responseText;
		if(resText != null && resText != ""){
			resText = resText.evalJSON();
		}
		var errMsg = resText.errMsg;
		if(errMsg != null){
			alert(errMsg);
			return;
		}
	}
	
	function commitCrmKey(){
		var crmApiKey = document.getElementById("crmApiKey").value;
		if(crmApiKey == ""){
			alert("请输入crmApiKey！");
			return false;
		}
		var url ='<%=basePath%>/manager/commitCrmApiKey.action?baihuiId=${baihuiId}&crmApiKey='+crmApiKey;
		new Ajax.Request(url,{
			onComplete : crmKeyVerify
		});
	}
	function crmKeyVerify(){
		
		alert("crmApiKey已经提交");
	}
	
	function check(){
			var set= document.getElementById("set");
			set.style.target="_blank";
			window.open("<%=basePath%>/schuduer_monitor.jsp?USERID=${baihuiId}&SIGN=${sign}");
		
	}
	
	function updateStatus(){
		window.location.href='<%=basePath%>/manager/updatePayUserStatus.action?baihuiId=${baihuiId}&appName=${appName}';
	}
	function show(){
		var div1 = document.getElementById("div1");
		if (div1.style.display == "none"){ 
			div1.style.display = "block";
		}
		var url = '<%=basePath%>/app?ACTION=importItemCatData&USERID=${baihuiId}&SIGN=${sign}&async=true';
		new Ajax.Request(url,{
			onComplete : callback1
		});
		
	}
	function callback1(response){
		document.getElementById('name').innerText="商品分类同步中...";
		var url = '<%=basePath%>/app?ACTION=viewImportItemCatDataProgress&USERID=${baihuiId}&SIGN=${sign}&async=true';
		new Ajax.Request(url,{
			onComplete : callback2
		});
	}
	function callback2(response){
		//alert(response)
		var ln = response.responseText;
	 	document.getElementById('progress').innerText=object[1]+ "%";
	}
		
</script>
</html>